import Vue from "vue";
import VueRouter from "vue-router";
import Router from "vue-router";

Vue.use(VueRouter);

const Layout = () => import("@/views/Layout");
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};

// const Home = () => import("@/views/home");
const routes = [
  {
    path: "/",
    component: Layout,
    name: "layout",
    redirect: "/home",
    children: [],
  },
  {
    path: "/login",
    component: () => import("@/views/login/index"),
  },
  {
    path: "*",
    component: () => import("@/views/not-found/index"),
  },
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});

export default router;
